package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.DictInfoDAO;

/**
 * Servlet implementation class deleteDictServlet
 */
public class deleteDictServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public deleteDictServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String dict_id = request.getParameter("dict_id");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/plain");
		PrintWriter out = response.getWriter();	
		Vector vt = new Vector();
        
		int start = 0 , next = 0 , end;
		end = dict_id.lastIndexOf(",");

		while(next != end)
		{
			next = dict_id.indexOf(",", start + 1);
			String str = dict_id.substring(start + 1, next);
			start = next;
			vt.addElement(str);
		}		
		DictInfoDAO dictDAO = new DictInfoDAO();
        dictDAO.deleteDictInfo(vt);
        out.print("{success:true,msg:'修改成功'}");               	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
